main(r,i,j,c){for(gets(&r);~scanf("%d%d",&r,&i);printf("%d\n",r<0?0:(c-r-1)*4+1)){r-=i;for(c=j=0;j<=r;j++)for(i=0;i<=r;i++)if(i*i+j*j<=r*r)c++;}}
